﻿/// <reference path="../Scripts/jquery/jquery-1.4.1-vsdoc.js" />

function NameAutoCompleteSelected(sender, args) {
    var nn = args.get_text();
    var uid = args.get_value();
    var textbox = $(sender.get_element());
    textbox.val("");
    textbox.focus();

    var q = textbox.prev().append($("<div class='left nameitem'>" + nn + " <a class='pointer' onclick='RemoveNameItem(this);'>x</a></div>").data("item", { uid: uid, nickname: nn }));
    //q.data("item", { uid: uid, nickname: nn });
    textbox.next("input:hidden").val(textbox.next("input:hidden").val()+uid + "|");
}

function RemoveNameItem(sender) {
    //$(sender).parent().remove();
    var q = $(sender).parent();
    var h = q.parent().nextAll("input:hidden");
    h.val(h.val().replace(q.data("item").uid + "|", ""));
    q.remove();
   // alert(q.data("item").uid);
}